<!---MAIN--->
	<div id="blog">
				<?php // POST LOOP: loop all the posts here
					$siteid = $site['id'];
					$postsqry = dbSelect('posts',array("site_id=$siteid","parent_id=0"),"ORDER BY publishdate DESC");
					if(mysql_numrows($postsqry) > 0){ 
					echo '<div class="posts" id="posts">';
					while($posts = mysql_fetch_array($postsqry)){
						/* echo '<h2>'.urldecode($posts['title']).'</h2>'; */
						echo '<div class="post">';
						$userid = $posts['author_id'];
						$author = mysql_fetch_array(dbSelect('users',array("id=$userid")));
						$authorname = $author['firstname'].' '.$author['lastname'];
						// if for some reason, the first and last name are not filled out, user first part of email. 
						if($authorname==""){
							$authoremail = $author['email']; 
							$authorexplode = explode('@',$authoremail);
							$authorname = $authorexplode[0];
						}
						$nicetime = nicetime($posts['publishdate']);
					echo'
					<span class="postcontent">
						<span id="postauthor">'.$authorname.'</span>&nbsp;'.urldecode($posts['post']);
						echo '<div id="postdatetime">';
						if($nicetime){echo $nicetime;} 
						echo '</div>
					</span>';
					// COMMENTS LOOP: loop all the comments here
						$commentsparentid = $posts['id'];
						$commentsqry = dbSelect('posts',array("site_id=$siteid","parent_id=$commentsparentid"));
					 	if(mysql_numrows($commentsqry) > 0){
						echo '<div class="comments">';
							while($comments = mysql_fetch_array($commentsqry)){
								$userid = $comments['author_id'];
								$commentsauthor = mysql_fetch_array(dbSelect('users',array("id=$userid")));
								$commentsauthorname = $commentsauthor['firstname'].' '.$commentsauthor['lastname'];
								// if for some reason, the first and last name are not filled out, use first part of email. 
								if($commentsauthorname==""){
									$commentsauthoremail = $commentsauthor['email'];
									$commentsauthorexplode = explode('@',$commentsauthoremail);
									$commentsauthorname = $commentsauthorexplode[0];
								}
								$commentsnicetime = nicetime($comments['publishdate']);
								echo  '<div class="comment rounded_comments">
												<span id="commentauthor">'.$commentsauthorname.'</span>
												<span class="commentcontent">'.urldecode($comments['post']).'</span>
												<span id="commentdatetime">'.$commentsnicetime.'</span>
											</div>';
					
						} /* end while */ 
						echo '</div><!--/comments-->';
						} /* end if */ 	
				echo '</div><!--/post-->';
				} /* end while */  
				echo '</div><!--/posts-->';
				} /* end if */  // POST LOOP: END
	echo '</div><!--/blog-->';